home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / workbench / directoryopus4 / dopus4_src / config / main7.c < prev    next >
C/C++ Source or Header  |  2000-03-11  |  17KB  |  586 lines

  1. /*
  2.  
  3. Directory Opus 4
  4. Original GPL release version 4.12
  5. Copyright 1993-2000 Jonathan Potter
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. All users of Directory Opus 4 (including versions distributed
  22. under the GPL) are entitled to upgrade to the latest version of
  23. Directory Opus version 5 at a reduced price. Please see
  24. http://www.gpsoft.com.au for more information.
  25.  
  26. The release of Directory Opus 4 under the GPL in NO WAY affects
  27. the existing commercial status of Directory Opus 5.
  28.  
  29. */
  30.  
  31. #include "config.h"
  32.  
  33. struct Gadget busygadget={
  34.     NULL,
  35.     0,0,0,0,
  36.     GFLG_GADGHNONE,0,GTYP_BOOLGADGET,
  37.     NULL,NULL,NULL,0,NULL,0,NULL};
  38. static int oldidcmp,busyflag;
  39.  
  40. void busy()
  41. {
  42.     if (!busyflag) {
  43.         busygadget.TopEdge=Window->BorderTop;
  44.         busygadget.LeftEdge=Window->BorderLeft;
  45.         busygadget.Width=Window->Width-Window->BorderLeft-Window->BorderRight;
  46.         busygadget.Height=Window->Height-Window->BorderTop-Window->BorderBottom;
  47.         AddGList(Window,&busygadget,0,1,NULL);
  48.         oldidcmp=Window->IDCMPFlags;
  49.         ModifyIDCMP(Window,IDCMP_CLOSEWINDOW);
  50.         Window->Flags|=WFLG_RMBTRAP;
  51.         SetBusyPointer(Window);
  52.         busyflag=1;
  53.     }
  54. }
  55.  
  56. void unbusy()
  57. {
  58.     if (busyflag) {
  59.         RemoveGList(Window,&busygadget,1);
  60.         ModifyIDCMP(Window,oldidcmp);
  61.         Window->Flags&=~WFLG_RMBTRAP;
  62.         ClearPointer(Window);
  63.         busyflag=0;
  64.     }
  65. }
  66.  
  67. void dosave(new)
  68. int new;
  69. {
  70.     char buf[80];
  71.  
  72.     busy();
  73.     if (new) {
  74. trysave:
  75.         makefilebuffer(configname);
  76.         filereq.flags=DFRF_SAVE;
  77.         filereq.title=cfg_string[STR_ENTER_CONFIGURATION_FILENAME];
  78.         filereq.window=Window;
  79.         if (!(FileRequest(&filereq))) {
  80.             unbusy();
  81.             return;
  82.         }
  83.         strcpy(configname,dirbuf);
  84.         TackOn(configname,filebuf,256);
  85.         if (!(strstri(configname,".CFG"))) StrConcat(configname,".CFG",256);
  86.     }
  87.     fixcstuff(&cstuff);
  88.     if (!SaveConfig(configname,&cstuff)) {
  89.         lsprintf(buf,cfg_string[STR_SAVE_FAILED],IoErr());
  90.         if (request(buf)) goto trysave;
  91.     }
  92.     else lchanged=changed=0;
  93.     unbusy();
  94. }
  95.  
  96. doload(type,def)
  97. int type,def;
  98. {
  99.     char *path,buf[80],*menulist[6],menuarray[6],**ftypelist,*typearray;
  100.     struct DOpusRemember *fkey;
  101.     struct ConfigStuff *newcstuff;
  102.     struct dopusgadgetbanks *bank,*bank2,*nbank;
  103.     struct dopusfiletype *ftype,*ntype;
  104.     struct dopushotkey *fhotkey,*nhotkey,*curhotkey;
  105.     int a,b,c,freecon=0,ret,m1,m2;
  106.  
  107.     busy();
  108.     fkey=NULL;
  109.     if (def) {
  110. tryload:
  111.         if (type==CFG_MAINMENU) path=configname;
  112.         else path=loadnamebuf;
  113.         makefilebuffer(path);
  114.         filereq.flags=0;
  115.         filereq.title=cfg_string[STR_SELECT_CONFIGURATION_TO_LOAD];
  116.         filereq.window=Window;
  117.         if (!(FileRequest(&filereq))) {
  118.             unbusy();
  119.             return(0);
  120.         }
  121.         strcpy(loadnamebuf,dirbuf);
  122.         TackOn(loadnamebuf,filebuf,256);
  123.         if (!(strstri(loadnamebuf,".CFG"))) StrConcat(loadnamebuf,".CFG",256);
  124.     }
  125.     if (!(newcstuff=AllocMem(sizeof(struct ConfigStuff),MEMF_CLEAR)) ||
  126.         !(newcstuff->config=AllocMem(sizeof(struct Config),MEMF_CLEAR))) {
  127.         if (newcstuff) FreeMem(newcstuff,sizeof(struct ConfigStuff));
  128.         unbusy();
  129.         return(0);
  130.     }
  131.     fixcstuff(&cstuff);
  132.     if (def) {
  133.         lchanged=changed=0;
  134.         SetBusyPointer(Window);
  135.         if ((a=ReadConfig(loadnamebuf,newcstuff))!=1) {
  136.             ClearPointer(Window);
  137.             if (a==ERROR_NOT_CONFIG) strcpy(buf,cfg_string[STR_FILE_NOT_VALID_CONFIGURATION]);
  138.             else lsprintf(buf,cfg_string[STR_OPEN_FAILED],a);
  139.             if (request(buf)) goto tryload;
  140.         }
  141.         else {
  142.             lchanged=1;
  143.             ClearPointer(Window);
  144.             CheckConfig(newcstuff);
  145.         }
  146.     }
  147.     else {
  148.         DefaultConfig(newcstuff);
  149.         lchanged=1;
  150.     }
  151.     if (lchanged) {
  152.         ret=1;
  153.         switch (type) {
  154.             case CFG_MAINMENU:
  155.                 FreeConfig(&cstuff);
  156.                 CopyMem((char *)newcstuff,(char *)&cstuff,sizeof(struct ConfigStuff));
  157.                 cstuff.config=config;
  158.                 CopyMem((char *)newcstuff->config,(char *)config,sizeof(struct Config));
  159.                 strcpy(configname,loadnamebuf);
  160.                 freecon=1;
  161.                 break;
  162.             case CFG_OPERATION:
  163.                 CopyMem((char *)&newcstuff->config->copyflags,(char *)&config->copyflags,
  164.                     (offsetof(struct Config,dynamicflags)-offsetof(struct Config,copyflags))+1);
  165.                 config->dateformat=newcstuff->config->dateformat;
  166.                 config->formatflags=newcstuff->config->formatflags;
  167.                 for (a=0;a<2;a++) {
  168.                     config->sortmethod[a]=newcstuff->config->sortmethod[a];
  169.                     config->separatemethod[a]=newcstuff->config->separatemethod[a];
  170.                     CopyMem((char *)newcstuff->config->displaypos[a],(char *)config->displaypos[a],16);
  171.                     CopyMem((char *)newcstuff->config->displaylength[a],(char *)config->displaylength[a],16);
  172.                 }
  173.                 freecon=3;
  174.                 break;
  175.             case CFG_GADGET:
  176.                 if (bank=firstbank) {
  177.                     while (bank->next) bank=bank->next;
  178.                 }
  179.                 bank2=newcstuff->firstbank;
  180.                 while (bank2) {
  181.                     if (nbank=(struct dopusgadgetbanks *)
  182.                             getcopy((char *)bank2,sizeof(struct dopusgadgetbanks),NULL)) {
  183.                         nbank->next=NULL;
  184.                         if (bank) bank->next=nbank;
  185.                         else firstbank=nbank;
  186.                         bank=nbank;
  187.                         copygadgets(bank2,bank,NULL);
  188.                     }
  189.                     bank2=bank2->next;
  190.                 }
  191.                 cstuff.firstbank=firstbank;
  192.                 freecon=3;
  193.                 break;
  194.             case CFG_MENU:
  195.                 freecon=3;
  196.                 for (a=0;a<6;a++) {
  197.                     menulist[a]=NULL;
  198.                     menuarray[a]=0;
  199.                 }
  200.                 for (a=0,b=0;a<5;a++) {
  201.                     if (newcstuff->config->menutit[a][0])
  202.                         menulist[b++]=newcstuff->config->menutit[a];
  203.                 }
  204.                 if (!menulist[0] ||
  205.                     !(dolistwindow(cfg_string[STR_SELECT_MENUS_TO_IMPORT],
  206.                         332,40,menulist,DLVF_MULTI|DLVF_HIREC,menuarray,NULL))) {
  207.                     ret=0;
  208.                     break;
  209.                 }
  210.                 for (a=0,b=0;a<5;a++) {
  211.                     m1=a*20; m2=(a+1)*20;
  212.                     for (c=m1;c<m2;c++)
  213.                         if (config->menu[c].name && config->menu[c].name[0]) break;
  214.                     if (c==m2) {
  215.                         while (!menuarray[b]) if ((++b)>4) break;
  216.                         if (b>4) break;
  217.                         for (c=m1;c<m2;c++) freenewfunction(&config->menu[c]);
  218.                         CopyMem((char *)&newcstuff->config->menu[b*20],
  219.                             (char *)&config->menu[m1],sizeof(struct dopusfunction)*20);
  220.                         for (c=m1;c<m2;c++) {
  221.                             config->menu[c].name=getcopy(config->menu[c].name,-1,NULL);
  222.                             config->menu[c].function=getcopy(config->menu[c].function,-1,NULL);
  223.                         }
  224.                         strcpy(config->menutit[a],newcstuff->config->menutit[b]);
  225.                         ++b;
  226.                     }
  227.                 }
  228.                 break;
  229.             case CFG_DRIVE:
  230.                 for (a=0;a<DRIVECOUNT;a++) freestring(config->drive[a].function);
  231.                 CopyMem((char *)newcstuff->config->drive,(char *)config->drive,sizeof(struct dopusfunction)*DRIVECOUNT);
  232.                 for (a=0;a<DRIVECOUNT;a++)
  233.                     config->drive[a].function=getcopy(newcstuff->config->drive[a].function,-1,NULL);
  234.                 freecon=3;
  235.                 break;
  236.             case CFG_FILETYPE:
  237.                 freecon=3;
  238.                 b=0;
  239.                 ftype=newcstuff->firsttype;
  240.                 while (ftype) {
  241.                     b++;
  242.                     ftype=ftype->next;
  243.                 }
  244.                 if (!(ftypelist=LAllocRemember(&fkey,(b+1)*4,MEMF_CLEAR)) ||
  245.                     !(typearray=LAllocRemember(&fkey,b+1,MEMF_CLEAR))) break;
  246.                 ftype=newcstuff->firsttype;
  247.                 for (a=0;a<b;a++) {
  248.                     ftypelist[a]=ftype->type;
  249.                     ftype=ftype->next;
  250.                 }
  251.                 if (!ftypelist[0] ||
  252.                     !(dolistwindow(cfg_string[STR_SELECT_FILETYPES_TO_IMPORT],
  253.                         332,72,ftypelist,DLVF_MULTI|DLVF_HIREC,typearray,NULL))) {
  254.                     ret=0;
  255.                     break;
  256.                 }
  257.                 ftype=newcstuff->firsttype; b=0;
  258.                 while (ftype) {
  259.                     if (typearray[b]) {
  260.                         if (ntype=(struct dopusfiletype *)
  261.                             getcopy((char *)ftype,sizeof(struct dopusfiletype),&typekey)) {
  262.                             ntype->next=NULL;
  263.                             ntype->recognition=getcopy(ftype->recognition,-1,&typekey);
  264.                             ntype->iconpath=getcopy(ftype->iconpath,-1,&typekey);
  265.                             for (a=0;a<FILETYPE_FUNCNUM;a++)
  266.                                 ntype->function[a]=getcopy(ftype->function[a],-1,&typekey);
  267.                             addfiletype(ntype);
  268.                         }
  269.                     }
  270.                     ftype=ftype->next; ++b;
  271.                 }
  272.                 cstuff.firsttype=firsttype;
  273.                 break;
  274.             case CFG_HOTKEYS:
  275.                 freecon=3;
  276.                 b=0;
  277.                 curhotkey=firsthotkey;
  278.                 while (curhotkey && curhotkey->next) curhotkey=curhotkey->next;
  279.                 fhotkey=newcstuff->firsthotkey;
  280.                 while (fhotkey) {
  281.                     b++;
  282.                     fhotkey=fhotkey->next;
  283.                 }
  284.                 if (!(ftypelist=LAllocRemember(&fkey,(b+1)*4,MEMF_CLEAR)) ||
  285.                     !(typearray=LAllocRemember(&fkey,b+1,MEMF_CLEAR))) break;
  286.                 fhotkey=newcstuff->firsthotkey;
  287.                 for (a=0;a<b;a++) {
  288.                     ftypelist[a]=fhotkey->name;
  289.                     fhotkey=fhotkey->next;
  290.                 }
  291.                 if (!ftypelist[0] ||
  292.                     !(dolistwindow(cfg_string[STR_SELECT_HOTKEYS_TO_IMPORT],
  293.                         332,72,ftypelist,DLVF_MULTI|DLVF_HIREC,typearray,NULL))) {
  294.                     ret=0;
  295.                     break;
  296.                 }
  297.                 fhotkey=newcstuff->firsthotkey; b=0;
  298.                 while (fhotkey) {
  299.                     if (typearray[b]) {
  300.                         if (nhotkey=(struct dopushotkey *)
  301.                             getcopy((char *)fhotkey,sizeof(struct dopushotkey),NULL)) {
  302.                             nhotkey->next=NULL;
  303.                             nhotkey->func.function=getcopy(fhotkey->func.function,-1,NULL);
  304.                             if (curhotkey) curhotkey->next=nhotkey;
  305.                             else firsthotkey=nhotkey;
  306.                             curhotkey=nhotkey;
  307.                         }
  308.                     }
  309.                     fhotkey=fhotkey->next; ++b;
  310.                 }
  311.                 cstuff.firsthotkey=firsthotkey;
  312.                 break;
  313.             case CFG_SCREEN:
  314.                 CopyMem((char *)&newcstuff->config->gadgettopcol,
  315.                     (char *)&config->gadgettopcol,
  316.                     offsetof(struct Config,pad4)-offsetof(struct Config,gadgettopcol));
  317.                 CopyMem(newcstuff->config->fontsizes,config->fontsizes,NUMFONTS);
  318.                 CopyMem(newcstuff->config->fontbufs,config->fontbufs,NUMFONTS*40);
  319.                 config->sliderbgcol=newcstuff->config->sliderbgcol;
  320.                 config->stringfgcol=newcstuff->config->stringfgcol;
  321.                 config->stringbgcol=newcstuff->config->stringbgcol;
  322.                 config->sliderwidth=newcstuff->config->sliderwidth;
  323.                 config->sliderheight=newcstuff->config->sliderheight;
  324.                 config->stringheight=newcstuff->config->stringheight;
  325.                 config->stringselfgcol=newcstuff->config->stringselfgcol;
  326.                 config->stringselbgcol=newcstuff->config->stringselbgcol;
  327.                 config->generalscreenflags=newcstuff->config->generalscreenflags;
  328.                 CopyMem((char *)newcstuff->config->scrollborders,
  329.                     (char *)config->scrollborders,sizeof(struct Rectangle)*2);
  330.                 CopyMem((char *)newcstuff->config->new_palette,
  331.                     (char *)config->new_palette,sizeof(ULONG)*48);
  332.                 strcpy(config->pubscreen_name,newcstuff->config->pubscreen_name);
  333.                 config->slider_pos=newcstuff->config->slider_pos;
  334.                 freecon=3;
  335.                 break;
  336.             case CFG_SYSTEM:
  337.                 CopyMem((char *)newcstuff->config->outputcmd,(char *)config->outputcmd,
  338.                     offsetof(struct Config,gadgetrows)-offsetof(struct Config,outputcmd));
  339.                 CopyMem((char *)newcstuff->config->startupscript,(char *)config->startupscript,
  340.                     offsetof(struct Config,pad8)-offsetof(struct Config,startupscript));
  341.                 strcpy(config->uniconscript,newcstuff->config->uniconscript);
  342.                 config->addiconflags=newcstuff->config->addiconflags;
  343.                 strcpy(config->shellstartup,newcstuff->config->shellstartup);
  344.                 strcpy(config->language,newcstuff->config->language);
  345.                 config->loadexternal=newcstuff->config->loadexternal;
  346.                 freecon=3;
  347.                 break;
  348.         }
  349.         lchanged=changed=0;
  350.     }
  351.     else {
  352.         freecon=1;
  353.         ret=0;
  354.     }
  355.     if (freecon&2) FreeConfig(newcstuff);
  356.     if (freecon&1) FreeMem(newcstuff->config,sizeof(struct Config));
  357.     FreeMem(newcstuff,sizeof(struct ConfigStuff));
  358.     cstufffix(&cstuff);
  359.     LFreeRemember(&fkey);
  360.     unbusy();
  361.     return(ret);
  362. }
  363.  
  364. void copyconfigonly(config1,config2)
  365. struct Config *config1,*config2;
  366. {
  367.     struct newdopusfunction *menubackup;
  368.     struct dopusfunction *drivebackup;
  369.     struct DOpusRemember *key;
  370.  
  371.     key=NULL;
  372.     menubackup=(struct newdopusfunction *)
  373.         getcopy((char *)config2->menu,sizeof(struct dopusfunction)*MENUCOUNT,&key);
  374.     drivebackup=(struct dopusfunction *)
  375.         getcopy((char *)config2->drive,sizeof(struct dopusfunction)*DRIVECOUNT,&key);
  376.     CopyMem((char *)config1,(char *)config2,sizeof(struct Config));
  377.     if (menubackup) CopyMem((char *)menubackup,(char *)config2->menu,sizeof(struct newdopusfunction)*MENUCOUNT);
  378.     if (drivebackup) CopyMem((char *)drivebackup,(char *)config2->drive,sizeof(struct dopusfunction)*DRIVECOUNT);
  379.     LFreeRemember(&key);
  380. }
  381.  
  382. dolistwindow(title,w,h,items,flags,selarray,item)
  383. char *title;
  384. int w,h;
  385. char **items;
  386. int flags;
  387. char *selarray;
  388. int *item;
  389. {
  390.     struct Window *wind;
  391.     struct DOpusListView *view;
  392.     ULONG class;
  393.     USHORT code;
  394.     int a,gadgetid,all=1,count;
  395.     char **gadtxt;
  396.  
  397.     listlist.w=w;
  398.     listlist.h=h;
  399.  
  400.     if (selarray && flags&DLVF_MULTI) {
  401.         listokaygad[0].NextGadget=&listokaygad[2];
  402.         listokaygad[2].NextGadget=&listokaygad[1];
  403.         gadtxt=listviewgads2;
  404.         count=3;
  405.     }
  406.     else {
  407.         listokaygad[0].NextGadget=&listokaygad[1];
  408.         gadtxt=listviewgads;
  409.         count=2;
  410.     }
  411.     listokaygad[1].NextGadget=NULL;
  412.  
  413.     setup_list_window(&requestwin,&listlist,listokaygad,count);
  414.  
  415.     listlist.items=items;
  416.     listlist.selectarray=selarray;
  417.     listlist.flags=flags;
  418.     listlist.itemselected=-1;
  419.     setuplist(&listlist,-1,-1);
  420.  
  421.     requestwin.Title=title;
  422.  
  423.     if (!(wind=openwindow(&requestwin))) return(0);
  424.  
  425.     listlist.window=wind;
  426.     if (!(AddListView(&listlist,1))) {
  427.         CloseWindow(wind);
  428.         return(0);
  429.     }
  430.  
  431.     SetAPen(wind->RPort,screen_pens[1].pen);
  432.     AddGadgets(wind,
  433.         listokaygad,
  434.         gadtxt,
  435.         count,
  436.         screen_pens[config->gadgettopcol].pen,screen_pens[config->gadgetbotcol].pen,1);
  437.     busy();
  438.  
  439.     FOREVER {
  440.         Wait(1<<wind->UserPort->mp_SigBit);
  441.         while (IMsg=(struct IntuiMessage *)GetMsg(wind->UserPort)) {
  442.             if ((view=ListViewIDCMP(&listlist,IMsg))==(struct DOpusListView *)-1) {
  443.                 class=IMsg->Class; code=IMsg->Code;
  444.                 if (class==IDCMP_GADGETUP || class==IDCMP_GADGETDOWN)
  445.                     gadgetid=((struct Gadget *)IMsg->IAddress)->GadgetID;
  446.                 ReplyMsg((struct Message *)IMsg);
  447.                 if (class==IDCMP_VANILLAKEY) {
  448.                     a=-1;
  449.                     if (code=='\r' || code=='o' || code=='y') a=0;
  450.                     else if (code=='' || code=='c' || code=='n') a=1;
  451.                     if (a!=-1) {
  452.                         SelectGadget(wind,&listokaygad[a]);
  453.                         class=GADGETUP; gadgetid=1-a;
  454.                     }
  455.                 }
  456.                 if (class==IDCMP_GADGETUP) {
  457.                     if (gadgetid<2) {
  458.                         unbusy();
  459.                         RemoveListView(&listlist,1);
  460.                         CloseWindow(wind);
  461.                         return(gadgetid);
  462.                     }
  463.                     else if (gadgetid==2 && flags&DLVF_MULTI) {
  464.                         for (a=0;a<listlist.count;a++) selarray[a]=all;
  465.                         RefreshListView(&listlist,1);
  466.                         all=1-all;
  467.                     }
  468.                 }
  469.             }
  470.             else if (view) {
  471.                 if (flags&DLVF_MULTI)
  472.                     selarray[view->itemselected]=1-selarray[view->itemselected];
  473.                 else {
  474.                     if (item) *item=view->itemselected;
  475.                     if (!(flags&DLVF_LEAVE)) {
  476.                         unbusy();
  477.                         RemoveListView(&cmdlist,1);
  478.                         CloseWindow(wind);
  479.                         return(1);
  480.                     }
  481.                 }
  482.             }
  483.         }
  484.     }
  485. }
  486.  
  487. void copytoclip(func,funclist,functype,flagsel)
  488. struct dopusfunction *func;
  489. char **funclist,*functype,*flagsel;
  490. {
  491.     struct Clip *newclip,*pos;
  492.  
  493.     busy();
  494.     if (newclip=LAllocRemember(&clipkey,sizeof(struct Clip),MEMF_CLEAR)) {
  495.         newclip->func.function=compilefunclist(funclist,functype,&clipkey);
  496.         newclip->func.which=getselflags(flagsel);
  497.         newclip->func.stack=atoi(edit_stackbuf);
  498.         newclip->func.pri=atoi(edit_prioritybuf);
  499.         newclip->func.delay=atoi(edit_delaybuf);
  500.         newclip->func.fpen=func->fpen;
  501.         newclip->func.bpen=func->bpen;
  502.         strcpy(newclip->name,edit_namebuf);
  503.         pos=firstclip;
  504.         while (pos && pos->next) pos=pos->next;
  505.         if (pos) pos->next=newclip;
  506.         else firstclip=newclip;
  507.         ++clipcount;
  508.     }
  509.     unbusy();
  510. }
  511.  
  512. pasteclip(func,funclist,functype,displist,flagsel)
  513. struct dopusfunction *func;
  514. char **funclist,*functype,**displist,*flagsel;
  515. {
  516.     char **cliplist;
  517.     struct DOpusRemember *key=NULL;
  518.     struct Clip *clip;
  519.     int a,b,ret=0;
  520.  
  521.     if (!clipcount) return(0);
  522.     if (!(cliplist=LAllocRemember(&key,(clipcount+1)*4,MEMF_CLEAR))) return(0);
  523.     busy();
  524.     clip=firstclip;
  525.     for (a=0;a<clipcount;a++) {
  526.         if (!clip) break;
  527.         if (!(cliplist[a]=LAllocRemember(&key,40,MEMF_CLEAR))) break;
  528.         strcpy(cliplist[a],clip->name);
  529.         clip=clip->next;
  530.     }
  531.     cliplist[a]=NULL;
  532.     if (dolistwindow(cfg_string[STR_SELECT_FUNCTION_TO_PASTE],
  533.         212,40,cliplist,DLVF_LEAVE|DLVF_HIREC,NULL,&a)) {
  534.         clip=firstclip;
  535.         for (b=0;b<a;b++) if (!(clip=clip->next)) break;
  536.         if (clip) {
  537.             erasefunction(func,funclist,displist,flagsel);
  538.             lsprintf(edit_stackbuf,"%ld",clip->func.stack);
  539.             lsprintf(edit_prioritybuf,"%ld",clip->func.pri);
  540.             lsprintf(edit_delaybuf,"%ld",clip->func.delay);
  541.             strcpy(edit_namebuf,clip->name);
  542.             func->key=0; func->qual=0;
  543.             func->fpen=clip->func.fpen; func->bpen=clip->func.bpen;
  544.             makefunclist(clip->func.function,funclist,functype);
  545.             for (a=0;a<MAXFUNCS;a++) makedispfunc(funclist[a],functype[a],displist[a]);
  546.             makeselflags(clip->func.which,flagsel);
  547.             ret=1;
  548.         }
  549.     }
  550.     LFreeRemember(&key);
  551.     unbusy();
  552.     return(ret);
  553. }
  554.  
  555. void makefilebuffer(buf)
  556. char *buf;
  557. {
  558.     char *ptr;
  559.  
  560.     strcpy(dirbuf,buf);
  561.     ptr=BaseName(dirbuf);
  562.     if (ptr>dirbuf) {
  563.         strcpy(filebuf,ptr);
  564.         *ptr=0;
  565.     }
  566.     else if (CheckExist(dirbuf,NULL)<1) {
  567.         dirbuf[0]=0;
  568.         strcpy(filebuf,buf);
  569.     }
  570. }
  571.  
  572. char *strstri(string,substring)
  573. char *string,*substring;
  574. {
  575.     int a,len,sublen;
  576.  
  577.     len=(strlen(string)-(sublen=strlen(substring)))+1;
  578.     if (len<1) return(NULL);
  579.  
  580.     for (a=0;a<len;a++) {
  581.         if (LStrnCmpI(&string[a],substring,sublen)==0)
  582.             return(string+a);
  583.     }
  584.     return(NULL);
  585. }
  586.